package com.ruoyi.logisticsaddress.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.logisticsaddress.domain.Logisticsaddress;
import com.ruoyi.logisticsaddress.service.ILogisticsaddressService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 配置地址Controller
 * 
 * @author sqlstudent
 * @date 2025-06-20
 */
@RestController
@RequestMapping("/logisticsaddress/logisticsaddress")
public class LogisticsaddressController extends BaseController
{
    @Autowired
    private ILogisticsaddressService logisticsaddressService;

    /**
     * 查询配置地址列表
     */
    @PreAuthorize("@ss.hasPermi('product:product:list')")
    @GetMapping("/list")
    public TableDataInfo list(Logisticsaddress logisticsaddress)
    {
        startPage();
        List<Logisticsaddress> list = logisticsaddressService.selectLogisticsaddressList(logisticsaddress);
        return getDataTable(list);
    }

    /**
     * 导出配置地址列表
     */
    @PreAuthorize("@ss.hasPermi('product:product:list')")
    @Log(title = "配置地址", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Logisticsaddress logisticsaddress)
    {
        List<Logisticsaddress> list = logisticsaddressService.selectLogisticsaddressList(logisticsaddress);
        ExcelUtil<Logisticsaddress> util = new ExcelUtil<Logisticsaddress>(Logisticsaddress.class);
        util.exportExcel(response, list, "配置地址数据");
    }

    /**
     * 获取配置地址详细信息
     */
    @PreAuthorize("@ss.hasPermi('product:product:list')")
    @GetMapping(value = "/{addressId}")
    public AjaxResult getInfo(@PathVariable("addressId") Long addressId)
    {
        return success(logisticsaddressService.selectLogisticsaddressByAddressId(addressId));
    }

    /**
     * 新增配置地址
     */
    @PreAuthorize("@ss.hasPermi('product:product:list')")
    @Log(title = "配置地址", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Logisticsaddress logisticsaddress)
    {
        return toAjax(logisticsaddressService.insertLogisticsaddress(logisticsaddress));
    }

    /**
     * 修改配置地址
     */
    @PreAuthorize("@ss.hasPermi('product:product:list')")
    @Log(title = "配置地址", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Logisticsaddress logisticsaddress)
    {
        return toAjax(logisticsaddressService.updateLogisticsaddress(logisticsaddress));
    }

    /**
     * 删除配置地址
     */
    @PreAuthorize("@ss.hasPermi('product:product:list')")
    @Log(title = "配置地址", businessType = BusinessType.DELETE)
	@DeleteMapping("/{addressIds}")
    public AjaxResult remove(@PathVariable Long[] addressIds)
    {
        return toAjax(logisticsaddressService.deleteLogisticsaddressByAddressIds(addressIds));
    }
}
